//
//  CountryViewController.m
//  TravelWorld
//
//  Created by dllo on 15/5/21.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "CountryViewController.h"

@interface CountryViewController ()
@property(nonatomic, retain) UIImageView *viewBG;
@end

@implementation CountryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"世界";
//    添加背景图片view
    self.viewBG = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64 - 49)];
    self.viewBG.backgroundColor = [UIColor darkGrayColor];
    self.viewBG.userInteractionEnabled = YES;
//    UIImage *worldBG = [UIImage imageNamed:@"WorldBG"];
//    viewBG.image = worldBG;
    
    UIView *alphView = [[UIView alloc] initWithFrame:self.viewBG.frame];
    alphView.backgroundColor = [UIColor whiteColor];
    alphView.alpha = 0.7;
    [self.view addSubview:self.viewBG];
    [self.viewBG addSubview:alphView];
    
    [self creatContinentsBtn];
}
- (void)creatContinentsBtn{
    //    添加各大洲的点击按钮
    UIButton *aisaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    aisaBtn.backgroundColor = [UIColor whiteColor];
    aisaBtn.layer.cornerRadius = 15;
    aisaBtn.layer.masksToBounds = YES;
    aisaBtn.frame = CGRectMake(
                               20,
                               20,
                               self.viewBG.frame.size.width / 2.6,
                               self.viewBG.frame.size.width / 2.6);
    [aisaBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    aisaBtn.tag = 1;
    [self.viewBG addSubview:aisaBtn];
    
    UIButton *europeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    europeBtn.backgroundColor = [UIColor whiteColor];
    europeBtn.layer.cornerRadius = 15;
    europeBtn.layer.masksToBounds = YES;
    europeBtn.frame = CGRectMake(
                                 self.viewBG.frame.size.width - self.viewBG.frame.size.width / 2.6 - 20,
                                 20,
                                 self.viewBG.frame.size.width / 2.6,
                                 self.viewBG.frame.size.width / 2.6);
    [europeBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    europeBtn.tag = 2;
    [self.viewBG addSubview:europeBtn];
    
    UIButton *northAmericaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    northAmericaBtn.backgroundColor = [UIColor whiteColor];
    northAmericaBtn.layer.cornerRadius = 15;
    northAmericaBtn.layer.masksToBounds = YES;
    northAmericaBtn.frame = CGRectMake(
                                       20,
                                       20 + aisaBtn.frame.size.height + 20,
                                       self.viewBG.frame.size.width / 2.6,
                                       self.viewBG.frame.size.width / 2.6);
    [northAmericaBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    northAmericaBtn.tag = 3;
    [self.viewBG addSubview:northAmericaBtn];
    
    UIButton *southAmericaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    southAmericaBtn.backgroundColor = [UIColor whiteColor];
    southAmericaBtn.layer.cornerRadius = 15;
    southAmericaBtn.layer.masksToBounds = YES;
    southAmericaBtn.frame = CGRectMake(
                                       self.viewBG.frame.size.width - self.viewBG.frame.size.width / 2.6 - 20,
                                       20 + aisaBtn.frame.size.height + 20,
                                       self.viewBG.frame.size.width / 2.6,
                                       self.viewBG.frame.size.width / 2.6);
    [southAmericaBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    southAmericaBtn.tag = 4;
    [self.viewBG addSubview:southAmericaBtn];
    
    UIButton *africaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    africaBtn.backgroundColor = [UIColor whiteColor];
    africaBtn.layer.cornerRadius = 15;
    africaBtn.layer.masksToBounds = YES;
    africaBtn.frame = CGRectMake(
                                 20,
                                 northAmericaBtn.frame.origin.y + northAmericaBtn.frame.size.height + 20,
                                 self.viewBG.frame.size.width / 2.6,
                                 self.viewBG.frame.size.width / 2.6);
    [africaBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    africaBtn.tag = 5;
    [self.viewBG addSubview:africaBtn];
    
    UIButton *oceaniaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    oceaniaBtn.backgroundColor = [UIColor whiteColor];
    oceaniaBtn.layer.cornerRadius = 15;
    oceaniaBtn.layer.masksToBounds = YES;
    oceaniaBtn.frame = CGRectMake(
                                  self.viewBG.frame.size.width - self.viewBG.frame.size.width / 2.6 - 20,
                                  northAmericaBtn.frame.origin.y + northAmericaBtn.frame.size.height + 20,
                                  self.viewBG.frame.size.width / 2.6,
                                  self.viewBG.frame.size.width / 2.6);
    [oceaniaBtn addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchUpInside];
    oceaniaBtn.tag = 6;
    [self.viewBG addSubview:oceaniaBtn];
}

- (void)buttonPress:(UIButton *)button{
    CountryListViewController *con = [[CountryListViewController alloc] init];
    con.buttonNumber = button.tag;
    NSLog(@"%ld", con.buttonNumber);
    con.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:con animated:YES];
    [con release];
}

























- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
